<script setup>
import ChartItem from "../components/chart/ChartItem.vue";
</script>

<template>
  <div id="app" class="app">
    <!-- <ChartType />s
    <Theme />
    <YAxis />
    <Language />
    <Tooltip />
    <Timezone />
    <Indicator /> -->
    <ChartItem  v-for="(minStep,i) in minSteps" :id="'overlay-k-line_'+i" :dataStep="minStep * 60 * 1000"></ChartItem>
    <!-- <Indicator /> -->
    <!-- <LoadMore />
    <Update /> -->
  </div>
</template>
<script>
import { mapState } from 'pinia'
import { crosshair,charts,currentChartId } from '../store.js'
export default{
  data(){
    return{
      minSteps : [1,5,15,30]
    }
  },
  computed:{
    ...mapState(crosshair, ['crosshair']),
    ...mapState(charts, ['charts']),
    ...mapState(currentChartId, ['currentChartId']),
  },
  watch:{
    crosshair(newVal,oldVal){
      if(!newVal) return; 
      for(let i = 0; i < this.charts.length; i++){
        const chart = this.charts[i];
        if(chart.id != this.currentChartId){
          // console.log('origin');
          // console.log(JSON.stringify(newVal));
          chart.getChartStore().getCrosshairStore().setFromData(newVal);
          // chart.getChartStore().getCrosshairStore().set(newVal);
        }
      }
    }
  }
}
</script>

<style>
body {
  margin: 0;
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f2f3f5;
}

div,
p {
  box-sizing: border-box;
}

p {
  margin: 0;
}

.app {
  display: flex;
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  padding: 15px;
}
.k-line-chart-container {
  display: flex;
  flex-direction: column;
  margin: 15px;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  background-color: #ffffff;
  width: 620px;
  height: 440px;
  padding: 16px 6px 16px 16px;
}

.k-line-chart-title {
  margin: 0;
  color: #252525;
  padding-bottom: 10px;
}

.k-line-chart {
  width: 100%;
  flex-grow: 1;
  overflow: hidden;
}
.k-line-chart-menu-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: #606060;
}
.k-line-chart-menu-container button {
  cursor: pointer;
  background-color: #1677ff;
  border-radius: 2px;
  margin-right: 8px;
  height: 24px;
  line-height: 26px;
  padding: 0 6px;
  font-size: 12px;
  color: #fff;
  border: none;
  outline: none;
}
</style>
